﻿CREATE PROCEDURE [ServiceEngine].[ListEntityGroupsByEntity]
  @entityID uniqueidentifier 
AS
BEGIN
 SET NOCOUNT ON;

 SELECT 
  N.[EntityID] as ID, 
  N.[EntityName] as [Name], 
  N.EntityDescription as Description
 FROM [ServiceEngine].Names N 
 JOIN [ServiceEngine].EntityGroups EG ON EG.EntityGroupID = N.[EntityID] 
 JOIN [ServiceEngine].Entities_EntityGroups EE ON EE.EntityGroupID = EG.EntityGroupID
 WHERE EE.EntityID = @entityID
END
